<template>
       <header>
           <i></i><span>智能定位预警系统平台</span>
           <el-dropdown class="user-area f-fr" trigger="click" @command="handelCommand">
               <span>{{user_info.account}}<label></label></span>
               <el-dropdown-menu slot="dropdown" class="login-out-area">
                   <el-dropdown-item command="out">注销登录</el-dropdown-item>
               </el-dropdown-menu>
           </el-dropdown>


       </header>
</template>
<script>
   export default{
         data(){
             return{
                 user_info:{},
             }
         },
         created(){
             this.user_info=store.user_info
         },
         methods:{
             handelCommand(type){
                 if(type){
                     if(type=='revise') this.changePassword()
                     else if(type=='out')  this.loginOut()
                 }
             },

             //设置cookie
             setCookie(name,value,days){
                 name=escape(name)
                 value=escape(value)
                 var expires=new Date()
                 expires.setTime(expires.getTime()+days*3600000*24)
                 document.cookie=name+"="+value+";expires="+ expires.toUTCString()
             },
             deleteCookie(name){
                 this.setCookie(name,'',-1)
             },
             loginOut(){
                     this.$http.post('admin_login/logout',{
                         adminid:this.user_info.adminid,
                         token:this.user_info.token
                     }).then(res=>{
                         if(!res.result){
                             this.$message('操作成功')
                             this.deleteCookie('admin_username')
                             this.deleteCookie('admin_password')
                             this.deleteCookie('admin_isRemember')
                             localStorage.removeItem('rights_manage_web_token')
                             window.location.href='login.html'
                         }
                     })
             }
         }
   }
</script>
<style lang="scss" scoped>
   header{
       height:60px;
       background:#fff;
       box-shadow:0 0 1px 0 inset #ccc;
       position:absolute;
       left:0;
       width:100%;
       z-index:10;
       i{
           margin-left:24px;
           vertical-align: middle;
           display:inline-block;
           width:40px;
           height:40px;
           background:url(./img/logo-new.png) center no-repeat;
           background-size:contain;
       }
       span{
           line-height:60px;
           font-size: 20px;
           color: #3B4144;
           margin-left:24px;
       }
    .user-area{
        cursor: pointer;
        margin:15px 30px 15px 0;
        height:30px;
        vertical-align: middle;
        span{
            font-size:16px;
            line-height:30px;
        }
        label{
            position: relative;
            margin-left:10px;
            display:inline-block;
            top:10px;
            width:0px;
            height:0px;
            line-height:30px;
            border-width:10px;
            border-style:solid;
            border-color:#333 #fff  #fff #fff;

        }
     }
     .login-out-area{
         width:100px;
     }
   }
</style>